package com.huaxin.hxrabbitmq;

import com.huaxin.hxrabbitmq.config.RabbitConfig;
import com.huaxin.hxrabbitmq.service.MessageSender;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;

@Configuration
@ConditionalOnClass(RabbitTemplate.class) // 只有存在 RabbitTemplate 时才加载
@Import({RabbitConfig.class})            // 导入配置
@ComponentScan(basePackages = "com.huaxin.hxrabbitmq") // 扫描 service 等组件
public class HxRabbitMQAutoConfiguration {

    // RabbitTemplate 来自 spring-boot-starter-amqp 自动配置
    // MessageSender 会被 ComponentScan 扫描到
}